package io.github.eric.urpc.example.msg;

import io.github.eric.urpc.core.rpc.Request;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

public class PingRequest extends Request {
    private long timestamp;
    private String msg;
    private Date date;
    private List<ChildMessage> childMessages;

    public PingRequest() {
        this.timestamp = System.currentTimeMillis();
        this.msg = String.valueOf(timestamp);
        this.date = new Date(timestamp);
        this.childMessages = new ArrayList<>();
        for (int i = 0; i < 2; i++) {
            this.childMessages.add(new ChildMessage());
        }
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public List<ChildMessage> getChildMessages() {
        return childMessages;
    }

    public void setChildMessages(List<ChildMessage> childMessages) {
        this.childMessages = childMessages;
    }

    @Override
    public String toString() {
        return "com.supos.dtc.core.proto.TestMessage#[ts=" + timestamp + ", msg=" + msg + "]";
    }

    public static class ChildMessage {
        private HashMap<String, String> map;
        private HashMap<String, List<Integer>> listMap;

        public ChildMessage() {
            this.map = new HashMap<>();
            this.map.put("test", String.valueOf(System.currentTimeMillis()));
            this.listMap = new HashMap<>();
            List<Integer> list = new ArrayList<>();
            list.add(1);
            list.add(2);
            this.listMap.put("testList", list);
        }

        public HashMap<String, String> getMap() {
            return map;
        }

        public void setMap(HashMap<String, String> map) {
            this.map = map;
        }

        public HashMap<String, List<Integer>> getListMap() {
            return listMap;
        }

        public void setListMap(HashMap<String, List<Integer>> listMap) {
            this.listMap = listMap;
        }
    }
}
